<template>
	<view class="todo-list">
		<u-cell-group>
				<u-cell-item title="资产名称" :value="cmdbDateil.name" :arrow="false"></u-cell-item>
				<u-cell-item title="资产状态" :value="cmdbDateil.status" :arrow="false"></u-cell-item>
				<u-cell-item title="资产IP" :value="cmdbDateil.ipConfig" :arrow="false"></u-cell-item>
				<u-cell-item title="使用状态" :value="cmdbDateil.useStatus" :arrow="false"></u-cell-item>
				<!-- <u-cell-item title="资产数量" :value="cmdbDateil.sum" :arrow="false"></u-cell-item> -->
				<u-cell-item title="资产创建时间" :value="cmdbDateil.createTime" :arrow="false"></u-cell-item>
				<u-cell-item title="资产在线状态" :value="cmdbDateil.online == '-1' ? '不在线': '在线'" :arrow="false"></u-cell-item>
				<u-cell-item title="资产类型" :value="cmdbDateil.typeName" :arrow="false"></u-cell-item>
				<u-cell-item title="资产位置" :value="cmdbDateil.siteName" :arrow="false"></u-cell-item>
				<u-cell-item title="是否盘点" :value="type == '0' ? '未盘点': type == '2' ? '已盘点': '未盘点'" :arrow="false"></u-cell-item>
				<!-- <u-cell-item title="是否盘点" :value="cmdbDateil.siteName" :arrow="false"></u-cell-item> -->
		</u-cell-group>
		
		<view style="width: 90%;margin-top: 20rpx;margin-bottom: 20rpx;display: flex;">
			<u-button type="primary" @click="onsubmit" v-if="type == '0'">盘点确认</u-button>
			<u-button type="primary" @click="onsubmit" v-if="type == '1'">盘盈记录</u-button>
			<u-button @click="endCheck">取消</u-button>
		</view>
		
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data () {
			return {
				id: "",
				cmdbId: "",
				type: "",
				cmdbDateil: {}
			}
		},
		onLoad(val) {
			this.id = val.checkId
			this.cmdbId = val.id
			this.getCmdbDateil()
		},
		methods: {
			// 获取详情
			getCmdbDateil () {
				this.$request('', '/offlineInspection/check/plan/checkIsAdd', 'get', {
					resourceId: this.cmdbId,
					checkId: this.id
				}, {}, ).then(res => {
						this.cmdbDateil = res.data.cmdb;
						this.type = res.data.type;
				})	
			},
			//盘点确认
			onsubmit () {
				this.$request('', '/offlineInspection/check/plan/checkResource', 'post', {
					resourceId: this.cmdbId,
					checkId: this.id
				}, {}, ).then(res => {
						this.$refs.uToast.show({
							title: '盘点完成',
							type: 'success',
							url: '/pages/Inventory/detail?id='+ this.id
						})
				})
			},
			lookpy () {
				uni.navigateTo({
					url:'/pages/Inventory/detail?id='+ this.id
				})
			},
			endCheck () {
				uni.navigateBack();
			}
		}
	}
</script>

<style>
	.todo-list {
		overflow: scroll;
		background-color: #fff;
		height: 100vh;
		width: 100%;
		display: flex;
		align-items: center;
		flex-direction: column;}
</style>